package flc.ast.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.stark.chess.ChessPrefUtil;

import flc.ast.R;
import flc.ast.activity.ChessActivity;
import flc.ast.databinding.FragmentHomeBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link HomeFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class HomeFragment extends BaseNoModelFragment<FragmentHomeBinding> {


    @Override
    protected int onCreate() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(getActivity(), mDataBinding.event1Container);
        EventStatProxy.getInstance().statEvent5(getActivity(), mDataBinding.event5Container);

        mDataBinding.ivChessLevel1.setOnClickListener(this);
        mDataBinding.ivChessLevel2.setOnClickListener(this);
        mDataBinding.ivChessLevel3.setOnClickListener(this);
        mDataBinding.ivChessLevel4.setOnClickListener(this);
        mDataBinding.ivChessLevel5.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        switch (v.getId()) {
            case R.id.ivChessLevel1:
                ChessPrefUtil.saveAiLevel(0);
                break;
            case R.id.ivChessLevel2:
                ChessPrefUtil.saveAiLevel(1);
                break;
            case R.id.ivChessLevel3:
                ChessPrefUtil.saveAiLevel(2);
                break;
            case R.id.ivChessLevel4:
                ChessPrefUtil.saveAiLevel(3);
                break;
            case R.id.ivChessLevel5:
                ChessPrefUtil.saveAiLevel(4);
                break;
        }
        startActivity(ChessActivity.class);
    }

    @Override
    protected void initData() {

    }
}